package com.ruoyi.web.controller.recipe;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.recipe.domain.RecipeFeedback;
import com.ruoyi.recipe.service.IRecipeFeedbackService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 反馈内容Controller
 * 
 * @author ruoyi
 * @date 2025-02-26
 */
@Controller
@RequestMapping("/recipe/feedback")
public class RecipeFeedbackController extends BaseController
{
    private String prefix = "recipe/feedback";

    @Autowired
    private IRecipeFeedbackService recipeFeedbackService;

    @RequiresPermissions("recipe:feedback:view")
    @GetMapping()
    public String feedback()
    {
        return prefix + "/feedback";
    }

    /**
     * 查询反馈内容列表
     */
    @RequiresPermissions("recipe:feedback:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(RecipeFeedback recipeFeedback)
    {
        startPage();
        List<RecipeFeedback> list = recipeFeedbackService.selectRecipeFeedbackList(recipeFeedback);
        return getDataTable(list);
    }

    /**
     * 导出反馈内容列表
     */
    @RequiresPermissions("recipe:feedback:export")
    @Log(title = "反馈内容", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(RecipeFeedback recipeFeedback)
    {
        List<RecipeFeedback> list = recipeFeedbackService.selectRecipeFeedbackList(recipeFeedback);
        ExcelUtil<RecipeFeedback> util = new ExcelUtil<RecipeFeedback>(RecipeFeedback.class);
        return util.exportExcel(list, "反馈内容数据");
    }

    /**
     * 新增反馈内容
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存反馈内容
     */
    @RequiresPermissions("recipe:feedback:add")
    @Log(title = "反馈内容", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(RecipeFeedback recipeFeedback)
    {
        return toAjax(recipeFeedbackService.insertRecipeFeedback(recipeFeedback));
    }

    /**
     * 修改反馈内容
     */
    @RequiresPermissions("recipe:feedback:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        RecipeFeedback recipeFeedback = recipeFeedbackService.selectRecipeFeedbackById(id);
        mmap.put("recipeFeedback", recipeFeedback);
        return prefix + "/edit";
    }

    /**
     * 修改保存反馈内容
     */
    @RequiresPermissions("recipe:feedback:edit")
    @Log(title = "反馈内容", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(RecipeFeedback recipeFeedback)
    {
        return toAjax(recipeFeedbackService.updateRecipeFeedback(recipeFeedback));
    }

    /**
     * 删除反馈内容
     */
    @RequiresPermissions("recipe:feedback:remove")
    @Log(title = "反馈内容", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(recipeFeedbackService.deleteRecipeFeedbackByIds(ids));
    }

    /**
     * 查询公告详细
     */
    @RequiresPermissions("recipe:feedback:list")
    @GetMapping("/view/{id}")
    public String view(@PathVariable("id") Long id, ModelMap mmap)
    {
        mmap.put("recipeFeedback", recipeFeedbackService.selectRecipeFeedbackById(id));
        return prefix + "/view";
    }
}
